package com.zzc.controller;

import com.alibaba.druid.util.StringUtils;
import com.zzc.common.JsonResult;
import com.zzc.common.TableResult;
import com.zzc.pojo.AdminUser;
import com.zzc.pojo.Customer;
import com.zzc.pojo.Role;
import com.zzc.service.AdminUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author zhouzhicheng
 * @version 1.0  2020/12/29
 */
@RestController
@RequestMapping("/sys/user")
public class AdminUserController {
    @Autowired
    private AdminUserService adminUserService;
    @RequestMapping("/table")
    public TableResult getUserList(String realName,String email,Integer status, Integer page,Integer limit){
        return adminUserService.getUserList(realName,email,status,page,limit);
    }
    @RequestMapping("/del")
    public JsonResult deleteUsersById(Integer[] ids){
        return adminUserService.deleteUserById(ids);
    }
    @RequestMapping("/add")
    public JsonResult addUser(AdminUser user){
        return adminUserService.insertUser(user);
    }
    @RequestMapping("/update")
    public JsonResult updateUser(AdminUser user){
        return adminUserService.updateByPrimaryKeySelective(user);
    }
    @RequestMapping("/user_role")
    public List<Integer> getUserRole(Integer userId){
        return adminUserService.getUserRole(userId);
    }
    @RequestMapping("/role_tree")
    public List<Role> getRoles(){
        return adminUserService.getRoles();
    }
    @RequestMapping("/assign_role")
    public JsonResult updateUserRole(Integer userId,Integer[] roleIds){
        return adminUserService.updateUserRole(userId,roleIds);
    }



}
